import React, { useState } from "react";
import Prompt from "./Prompt";

const App = () => {
  const [text, setText] = useState("");

  const fn = (e) => {
    setText(e.target.value);
  };
  return (
    <>
      <h2>路由保护</h2>
      <input type="text" value={text} onChange={fn} />
      <Prompt
        when={text !== ""}
        message={() => {
          alert();
          return true;
        }}
      />
    </>
  );
};

export default App;
